package manager.modulo.ordemservico.fonte;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.LinkedList;
import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.table.TableRowSorter;
import manager.auxiliares.AutoComplete;
import manager.auxiliares.Icons;
import manager.auxiliares.MensagemExcessao;
import manager.helpers.table.TableRowComparator;
import manager.interfaces.InterfaceRegister;
import manager.modulo.ordemservico.dao.ProcedimentoDao;

/**
 *
 * @author Thiago
 */
public class RegistroProcedimento implements InterfaceRegister {

    private JanelaProcedimento janelaProcedimento;

    public LinkedList buscaAutoCompletar(String option, String search) {
        LinkedList<String> result = new LinkedList<String>();
        try {
            result = new ProcedimentoDao().buscar(option, search, true);
        } catch (SQLException ex) {
            MensagemExcessao.mostrarMensagem(ex, "Auto Completar de Procedimento");
        }
        return result;
    }

    public LinkedList buscaTabela(String option, String search) {
        LinkedList result = new LinkedList();
        try {
            result = ProcedimentoDao.buscaTabela(option, search);
        } catch (SQLException ex) {
            MensagemExcessao.mostrarMensagem(ex, "Buscando Procedimento");
        }
        return result;
    }

    public String getTituloEntidade() {
        return "Procedimento";
    }

    public LinkedList<String> getOpcoesBusca() {
        LinkedList<String> searchOption = new LinkedList<String>();
        searchOption.add("Nome do Procedimento");
        return searchOption;
    }

    public void changeOptionSearch(AutoComplete autoComplete, String option, JComboBox jComboBoxValue) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public LinkedList<String> getNomeColunaTabela() {
        LinkedList<String> columnNames = new LinkedList<String>();
        columnNames.add("");
        columnNames.add("Nome");
        columnNames.add("Valor");
        columnNames.add("");
        return columnNames;
    }

    public void inserirEntidade() {
        if (janelaProcedimento != null) {
            janelaProcedimento.dispose();
        }
        janelaProcedimento = new JanelaProcedimento(0);
    }

    public void editarEntidade(int id) {
        if (janelaProcedimento != null) {
            janelaProcedimento.dispose();
        }
        janelaProcedimento = new JanelaProcedimento(id);
    }

    public void imprimir(int id) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public TableRowSorter getTableSorter() {
        TableRowComparator tableRowComparator = new TableRowComparator();
        return tableRowComparator;
    }

    public String getTituloBuscaPadrao() {
        return "Nome do Procedimento";
    }

    public boolean isAdd() {
        return true;
    }

    public boolean isEdit() {
        return true;
    }

    public boolean isRemove() {
        return false;
    }

    public boolean isFiles() {
        return false;
    }

    public boolean isExport() {
        return false;
    }

    public boolean isPrint() {
        return false;
    }

    public ImageIcon getModuleIcon() {
        return new Icons().getModuloOrdemServico();
    }

    public int getColumnCount() {
        return getNomeColunaTabela().size();
    }

    public boolean isFilter() {
        return false;
    }

    public void filtro() {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    public boolean temFiltroHabilitado() {
        return false;
    }

    public HashMap<String, Object> getFiltros() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
}
